package br.com.clebao.droidcontroler.persistencia;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public abstract class DAODroid<L> implements DAO<L>{

	protected BancoDadosHelper helper;
	protected SQLiteDatabase db;
	protected String tableName;
	protected Context contexto;
	
	
	public DAODroid(Context c) {
		this.contexto = c;
		setTableName();
	}
	
	public SQLiteDatabase openDB(){
		helper = new BancoDadosHelper(contexto);
		db = helper.getReadableDatabase();		
		return db;
		
	}
	
	
	public void closeDB(){
		db.close();
	}
	
	

	public abstract long addObject(L obj);

	public abstract boolean updateObject(L obj);

	public abstract Cursor findObject(int id);

	public abstract Cursor findAllObject();

}
